package tankgame06;

import java.util.Vector;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/12
 * @time 18:57
 */
public class Hero extends Tank {
    Bullet bullet = null;
    boolean isAlive = true;
    //保存多颗子弹
    Vector<Bullet> bullets = new Vector();
    public Hero(int x, int y) {
        super(x, y);
        this.setType(1);
    }

    @SuppressWarnings("all")
    public void shootEnemyTank(){
        if (bullets.size() == 5){
            return;
        }

        switch (getDirection()){
            //上
            case 0:
                bullet = new Bullet(getX() + 20,getY(),getDirection());
                break;
            //右
            case 1:
                bullet = new Bullet(getX()+ 60, getY() + 20,getDirection());
                break;
            case 2:
                bullet = new Bullet(getX()+20,getY()+60,getDirection());
                break;
            case 3:
                bullet = new Bullet(getX(),getY()+20,getDirection());
                break;
        }
        bullets.add(bullet);
        //启动线程
        new Thread(bullet).start();
    }
}
